home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5099 < prev    next >
Encoding:
Text File  |  1996-08-06  |  2.0 KB  |  68 lines

  1. Path: kom22.ethz.ch!conrad
  2. From: conrad@kom22.ethz.ch (Christian Conrad)
  3. Newsgroups: comp.lang.c++
  4. Subject: Visible/Invisible Class definitions ?
  5. Date: 2 Feb 1996 12:42:24 GMT
  6. Organization: Swiss Federal Institute of Technology (ETHZ)
  7. Message-ID: <4et0rg$22d@elna.ethz.ch>
  8. NNTP-Posting-Host: kom22-e.ethz.ch
  9. X-Newsreader: TIN [version 1.2 PL1]
  10.  
  11. Hello,
  12.  
  13. I am quite new in the C++ programmation and I have now the following
  14. general question:
  15.  
  16. I am building a library of approx. 3-4 base classes. Each class
  17. has a visible part (public) which must be used by the application
  18. programmer (the future user of the provided library) and a
  19. private/protected part which may be quite large.
  20.  
  21. I would like to hide all the complexity and the internal details to
  22. the application programmer, and provide him only with the "public"
  23. part of the classes he needs. I did the following:
  24.  
  25.     class X_private {
  26.  
  27.       protected:
  28.         // internal stuff, not relevant for the programmer
  29.     };
  30.  
  31.     class X : private X_private {
  32.  
  33.       public:
  34.  
  35.         // relevant information for the programmer
  36.     };
  37.  
  38. I can separate these definitions in two distinct header files, by doing
  39. so, the programmer will still "see" the internal details by viewing the
  40. corresponding header file ! How to avoid this ? If everything is private,
  41. then the programmer cannot use it, so why should he see it ?
  42.  
  43. This issue can be avoided in C by providing forward declarations, is there
  44. an equivalent mechanism in C++ ?
  45.  
  46. Thanks for each answer.
  47.  
  48. Christian Conrad
  49.  
  50. --
  51.  
  52.  ---------------------------     % % % % %     ---------------------------
  53.                                         %
  54.  Christian CONRAD                      %            
  55.                                       %        Tel. (+41) 1 / 632 7015       
  56.  ETH-Zurich                          %         Fax  (+41) 1 / 632 1035        
  57.    Technische Informatik und        %          E-Mail: conrad@tik.ee.ethz.ch   
  58.    Kommunikationsnetze (TIK)       %       
  59.                                   %        
  60. ----------------------------     % % % % %     ---------------------------
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.